
package com.zhu.salesmanagement;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import com.zhu.salesmanagement.common.Actions;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.SimpleAdapter;

public class VisitListActivity extends Activity {
    private GridView gridview = null;
    private ArrayList<HashMap<String, Object>> meumList = new ArrayList<HashMap<String, Object>>();
    private ImageView mImageView = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.layout_main_grid);

        setupView();
        initData();
    }

    public void onResume() {
        super.onResume();
        Actions.setAutoTime(this);
    }

    private void setupView() {
        gridview = (GridView) findViewById(R.id.GridView);
        mImageView = (ImageView) findViewById(R.id.image);
    }

    private void initData() {
        String[] name = this.getResources().getStringArray(R.array.visitlist_item);
        for (int i = 0; i < name.length; i++) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("ItemImage", R.drawable.ic_launcher);
            map.put("ItemText", name[i]);
            meumList.add(map);
        }
        SimpleAdapter saMenuItem = new SimpleAdapter(this, meumList,
                R.layout.layout_main_item,
                new String[] {
                        "ItemImage", "ItemText"
                },
                new int[] {
                        R.id.ItemImage, R.id.ItemText
                });
        gridview.setAdapter(saMenuItem);
        gridview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
                if (arg2 == 0) {

                } else if (arg2 == 1) {
                	gotoVisitTaskActivity();
                }else if(arg2 == 2){
                	
                }
            }
        });
    }

    private void gotoProductInfoActivity() {
        Intent tent = new Intent(VisitListActivity.this, ProductInfoListActivity.class);
        VisitListActivity.this.startActivity(tent);
    }

    private void gotoVisitTaskActivity() {
        Intent tent = new Intent(VisitListActivity.this, VisitTaskListActivity.class);
        VisitListActivity.this.startActivity(tent);
    }
}
